package com.api.weaver.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

@RestController
public class DiceController {
    private final Random random = new Random();

    @GetMapping("/api/roll")
    public Map<String, Object> rollDice() {
        int result = random.nextInt(6) + 1;
        Map<String, Object> map = new HashMap<>();
        map.put("result", result);
        return map; // 返回 JSON: {"result":3}
    }
}
